//
//  CJIntroductionHeader.m
//  CoJellyCartoon
//
//  Created by dllo on 16/4/6.
//  Copyright © 2016年 CJG. All rights reserved.
//

#import "CJIntroductionHeader.h"

@interface CJIntroductionHeader ()<UICollectionViewDataSource, UICollectionViewDelegate>
@property (nonatomic, strong)UICollectionViewFlowLayout *flowlayout;
@end
@implementation CJIntroductionHeader


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.title = [[CJBaseLabel alloc] initWithFrame:CGRectZero];
        self.title.font = [UIFont systemFontOfSize:15];
        self.title.numberOfLines = 2;
        [self addSubview:self.title];
        
        self.PlayPic = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.PlayPic.image = [UIImage imageNamed:@"recplaycountpic"];
        [self addSubview:self.PlayPic];
        self.playCount = [[CJBaseLabel alloc] initWithFrame:CGRectZero];
        self.playCount.font = [UIFont systemFontOfSize:12];
        self.playCount.textColor = [UIColor lightGrayColor];
        [self addSubview:self.playCount];
        self.CommentsPic = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.CommentsPic.image = [UIImage imageNamed:@"pinglun"];
        [self addSubview:self.CommentsPic];
        self.commentsCount = [[CJBaseLabel alloc] initWithFrame:CGRectZero];
        self.commentsCount.font = [UIFont systemFontOfSize:12];
        self.commentsCount.textColor = [UIColor lightGrayColor];
        self.descriptionLabel = [[CJBaseLabel alloc] initWithFrame:CGRectZero];
        self.descriptionLabel.textColor = [UIColor lightGrayColor];
        self.descriptionLabel.font = [UIFont systemFontOfSize:15];
        
//        [self creatColletion];
        [self addSubview:self.descriptionLabel];
        
    }
    return self;
}
-(void)creatColletion{
    self.flowlayout = [[UICollectionViewFlowLayout alloc] init];
    
    self.FunctionColleciton = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:self.flowlayout];
    self.FunctionColleciton.delegate = self;
    self.FunctionColleciton.dataSource = self;
    
    [self.FunctionColleciton registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"reuse"];
    
    [self addSubview:self.FunctionColleciton];
    
}
-(void)layoutSubviews{
    [super layoutSubviews];
    self.flowlayout.itemSize = CGSizeMake(self.bounds.size.width/4, self.bounds.size.width/4);
    self.flowlayout.minimumInteritemSpacing = 0;
    self.flowlayout.minimumLineSpacing = 0;
//    self.title.frame = CGRectMake(5, 5, self.bounds.size.width - 20, 20);
    self.PlayPic.frame = CGRectMake(5, self.title.bounds.origin.y + self.title.bounds.size.height+10, 20, 20);
    self.playCount.frame = CGRectMake(self.PlayPic.bounds.origin.x + self.PlayPic.bounds.size.width + 3, self.title.bounds.origin.y + self.title.bounds.size.height+10, 50, 20);
    self.CommentsPic.frame = CGRectMake(self.playCount.bounds.origin.x + self.playCount.bounds.size.width + 20, self.title.bounds.origin.y + self.title.bounds.size.height+10, 20, 20);
    self.commentsCount.frame = CGRectMake(self.CommentsPic.bounds.origin.x + self.CommentsPic.bounds.size.width + 3 , self.title.bounds.origin.y + self.title.bounds.size.height+10, 60, 20);
    self.descriptionLabel.frame = CGRectMake(5, self.playCount.bounds.origin.y+self.playCount.bounds.size.height+20, self.bounds.size.width, 40);
    self.FunctionColleciton.frame = CGRectMake(self.center.x-self.center.x/2, self.descriptionLabel.frame.size.height + self.descriptionLabel.frame.origin.y, self.bounds.size.width/2, self.bounds.size.width/4);
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return 2;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"reuse" forIndexPath:indexPath];
    
    cell.backgroundColor = [UIColor orangeColor];
    
    return cell;
}
@end
